﻿using Business.Service;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcAppWeb.Controllers
{
    public class DCInventoryMoveController : BaseDataController
    {

        public ActionResult DCInventoryMove()
        {
            if (Session["UserInfo"] == null) return RedirectToAction("LogOn", "Account");
            else
            {
                AppUserList model = (AppUserList)Session["UserInfo"];
                return View(model);

            }
        }


        ///<summary>
        ///查询前置仓库存转仓信息
        ///</summary>
        ///<returns></returns>
        public JsonResult InitJsonResult(string moveCode, string requestWareHouseId, string targetWareHouseId, string goodsCode, string goodsName, string status)
        {
            string where = "  where 1=1 ";
            int page = int.Parse(Request["page"].ToString());
            int rows = int.Parse(Request["rows"].ToString());
            int total = 0;
            if (moveCode != "")
            {
                where += " and t1.inventoryMoveCode like '%" + moveCode + "%'";
            }
            if (requestWareHouseId != "" && requestWareHouseId != "0")
            {
                where += " and t1.requestwarehouseid = " + requestWareHouseId + "";
            }
            if (targetWareHouseId != "" && targetWareHouseId != "0")
            {
                where += " and t1.targetWareHouseId = " + targetWareHouseId + "";
            }
            if (goodsCode != "")
            {
                where += " and t6.goodsCode like '%" + goodsCode + "%'";
            }
            if (goodsName != "")
            {
                where += " and t6.goodsName like '%" + goodsName + "%'";
            }
            if (status != "")
            {
                where += " and t1.status='" + status + "'";
            }
            var retData = new object();
            BDCInventory db = new BDCInventory();
            retData = db.GetDCInventoryMove(page, rows, out total, where).ToList();
            Dictionary<string, object> json = new Dictionary<string, object>();
            json.Add("total", total);
            json.Add("rows", retData);
            return Json(json);
        }

    }
}
